refactor(OracleComp): make OracleComp/OracleQuery reducible over PolyFun - #490
Conversation
…PolyFun Make `OracleComp`, `OracleQuery`, and `OracleSpec.toPFunctor` reducible aliases of their `PolyFun` counterparts and delete the bespoke `Monad`/`LawfulMonad`/`MonadLift`/`Functor` instances, so PolyFun's own instances and lemmas apply directly to oracle computations. Repair the resulting breakage: restate `Traversal` over `PFunctor.FreeM.Cursor`, re-key `toPFunctor_add` off the simp set, narrow ReplayFork's local transparency to `PFunctor.Idx`, route invariant-preservation proofs via `simulateQ_spec_query`, and align the `@[vcspec]`/`@[wpStep]` registry lookups with `Sym` pattern preprocessing via `symMatchKey`. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
🤖 PR SummaryFailed to generate AI summary. Please check the per-file summaries and statistics below. Statistics
Lean Declarations ✏️ Removed: 4 declaration(s)
✏️ Added: 10 declaration(s)
✏️ Affected: 9 declaration(s) (line number changed)
📋 **Additional Analysis**No new style or policy violations introduced; the diff is a systematic refactoring to rename 📄 **Per-File Summaries**
Last updated: 2026-07-22 14:31 UTC. |
Build Timing Report
Incremental Rebuild Signal
This compares a clean project build against an incremental rebuild in the same CI job; it is a lightweight variability signal, not a full cross-run benchmark. Slowest Current Clean-Build FilesShowing 20 slowest current targets, with comparison against the selected baseline when available.
|
🤖 AI ReviewOverall Summary: Errors during review:
🔗 **Cross-File Analysis**Cross-file analysis failed: 400 INVALID_ARGUMENT. {'error': {'code': 400, 'message': 'API key not valid. Please pass a valid API key.', 'status': 'INVALID_ARGUMENT', 'details': [{'@type': 'type.googleapis.com/google.rpc.ErrorInfo', 'reason': 'API_KEY_INVALID', 'domain': 'googleapis.com', 'metadata': {'service': 'generativelanguage.googleapis.com'}}, {'@type': 'type.googleapis.com/google.rpc.LocalizedMessage', 'locale': 'en-US', 'message': 'API key not valid. Please pass a valid API key.'}]}} 📄 **Review for `Examples/PRGfromPRF.lean`**An error occurred while analyzing 📄 **Review for `VCVio/CryptoFoundations/FiatShamir/Sigma/Stateful/Compatibility.lean`**An error occurred while analyzing 📄 **Review for `VCVio/CryptoFoundations/ReplayFork.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/OracleComp.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/OracleQuery.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/OracleSpec.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/SimSemantics/StateT/PreservesInv.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/SimSemantics/WriterT/PreservesInv.lean`**An error occurred while analyzing 📄 **Review for `VCVio/OracleComp/Traversal.lean`**An error occurred while analyzing 📄 **Review for `VCVio/ProgramLogic/Tactics/Common/Core.lean`**An error occurred while analyzing 📄 **Review for `VCVio/ProgramLogic/Tactics/Common/Registry.lean`**An error occurred while analyzing 📄 **Review for `VCVio/ProgramLogic/Tactics/Common/WpStepRegistry.lean`**An error occurred while analyzing 📄 **Review for `VCVio/StateSeparating/CellRef.lean`**An error occurred while analyzing |
|
@quangvdao would be good to know if you see this as the right fix for mvcgen breakage |
* refactor(OracleComp): consume generic PolyFun traversal predicates * chore: pin merged PolyFun traversal API
🤖 PR SummaryThe pull request refactors the VCVio library to make Statistics
Lean Declarations ✏️ Removed: 4 declaration(s)
✏️ Added: 10 declaration(s)
✏️ Affected: 9 declaration(s) (line number changed)
📋 **Additional Analysis**The diff is a large refactor/rename 📄 **Per-File Summaries**
Last updated: 2026-07-25 16:15 UTC. |
Retarget of the fork-golf refactor onto post-#490 main. Infra conflicts (lake-manifest, lakefile, OracleSpec, Tactics/Common/Core, program-logic docs) resolve to main; ReplayFork.lean takes the refactored version, which already contains #490's edits via its merged base. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Motivation
OracleComp specandOracleQuery specare the free monad and object action ofspec.toPFunctor. Before this PR, VCVio wrapped those objects with a second setof forwarding instances. The wrappers were definitionally equal to PolyFun's
objects but not transparent enough for rewriting, instance lookup, and generic
PolyFun APIs to share one stable representation.
This PR makes that relationship explicit and repairs every downstream place
where the former abstraction seam affected normalization. It also updates
VCVio to PolyFun
mainat2964499.Semantic changes
One canonical free-monad representation
OracleComp,OracleQuery, andOracleSpec.toPFunctor@[reducible].Monad,LawfulMonad,MonadLift,Functor, andLawfulFunctorinstances; the corresponding PolyFun instances now applydirectly.
QueryImpl.eq_handler,QueryImpl.Stateful.eq_handler, andQueryImpl.Stateful.runState_eq_handler_runidentify VCVio's oracle-shapedAPIs with PolyFun's effectful handler APIs.
Traversal predicates use the PolyFun tree structure
allPathsSatisfyandsomePathSatisfiesretain their public names and logicalbehavior, but are now defined over
PFunctor.FreeM.Cursor, filtered byTraceList.DirectionsWithinand interpreted byFreeM.RootSatisfies.Using cursors is important: a nonterminal cursor observes a demanded query even
when the allowed answer set is empty and therefore no complete path exists.
The pure, query/bind, general bind, and
supportWhenbridge theorems arereproved against this representation.
Program-logic registry keys stay aligned
Making the wrappers reducible changes the keys stored by Lean's
Sym.DiscrTree. The newsymMatchKeyhelper narrowly unfolds exactlyOracleComp,OracleQuery, andOracleSpec.toPFunctorbefore all unary,relational, and
wpSteplookups. This restoresvcstep/vcgenmatching forplain
pure, bind, and query goals without broadly unfolding user programs.The narrower implementation is intentional: applying the general
Sym.preprocessTypeto goal terms can unfold matchers containing loose deBruijn variables and panic in Lean 4.32.
PolyFun interaction cutover
29644990ebc2828ca09170bc9d398649cd9f5950.example from historical
Spec/Transcriptvocabulary toTypeTree/Path.TypeTree.Fintypesupplies finite branching andTypeTree.Nonemptysuppliesmove availability.
Sampler.uniformanduniformInow require both.Handler normalization ownership
handler_nfrules forFreeM,PFunctor.Handler.Stateful,StateT, and standardWriterT.handler_simpset to oracle simulation, queryinstrumentation, caching, and local WriterT compatibility equations.
handler_stepcomposehandler_nfwithhandler_simpingeneric-to-specific order.
stateful-handler normalization through the VCVio tactic.
Normalization repairs
@[simp]fromOracleSpec.toPFunctor_add; rewriting it inside aninstance-carrying
OracleComptype prevents thesimulateQ_queryfamilyfrom matching.
PFunctor.Idxlocally reducible inReplayFork; globalreducibility of
toPFunctorsupplies the other required transparencywithout changing instance lookup keys locally.
simulateQ_spec_query.tactic-shape adjustment in
PRGfromPRF.Scope
The PR changes representation transparency and proof/API plumbing. It does not
change
simulateQ, probability semantics, cryptographic games, winning events,or security bounds. It introduces no new axioms,
sorry,admit, orstop.Validation
Validated locally on exact head
a62b2feb7b8abea9c82288ce704630a89665f9b4with:lake build ToMathlib VCVio FFI LatticeCrypto HashSig Examples VCVioWidgetslake env lean VCVioTest/Smoke.leanlake exe lint-style ToMathlib VCVio FFI LatticeCrypto Examples VCVioWidgets Interopgit diff --checkThe build emits only the repository's pre-existing
sorrywarnings.